<%@ include file="/html/portlet/ext/registration/init.jsp" %>

<%
	String tabs1 = ParamUtil.getString(request, "tabs1", "New");
	
	PortletURL tabs1URL = renderResponse.createRenderURL();
	tabs1URL.setParameter("struts_action", "/ext/registration/viewRegistration");
	tabs1URL.setParameter(Constants.CMD, "mainstay-tab"); 
	tabs1URL.setParameter("tabs1", tabs1);
	//String tabs1Values = LanguageUtil.get(pageContext, "school")+","+LanguageUtil.get(pageContext, "student")+","+LanguageUtil.get(pageContext, "parent")+","+LanguageUtil.get(pageContext, "teacher")+","+LanguageUtil.get(pageContext, "others");
	//String tabs1Names = StringUtil.replace(tabs1Values, StringPool.UNDERLINE, StringPool.DASH);
%>

<liferay-ui:tabs
	names="New,Approved,Pending,Rejected"
	param="tabs1"
	url="<%= tabs1URL.toString() %>"
/>	

<c:choose>
	<c:when test='<%= tabs1.equals("New") %>'>
	
	<%
		List<Mainstay> mainstayNew = MainstayLocalServiceUtil.getByStatus(0);
		SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, 5, tabs1URL, null, "");
		List mainstayList = ListUtil.subList(mainstayNew, searchContainer.getStart(), searchContainer.getEnd());
		int total = mainstayNew.size();
		searchContainer.setTotal(total);
	%>

	<center>
	<table class="taglib-search-iterator" style="width:100%" cellspacing="0" cellpadding="2">
		<tr class='results-header'>
			<th><liferay-ui:message key="sNo" /></th>
			<th><liferay-ui:message key="first-name" /></th>	
			<th><liferay-ui:message key="middle-name" /></th>
			<th><liferay-ui:message key="last-name" /></th>
			<th></th>
		</tr>	

	<%
		for(int i=0; i<mainstayList.size(); i++){

			Mainstay mainstay = (Mainstay) mainstayList.get(i);
			String className = ( ( i%2 == 0 ) ? "portlet-section-body results-row" : "portlet-section-body results-row alt"); 
			String classNameHover = className+" hover";
	%>
		<tr class='<%= className %>'; onmouseout="this.className = '<%=className%>'" onmouseover="this.className = '<%=classNameHover%>'"> 
			<td><%= Integer.toString(searchContainer.getStart() + i + 1)%></td>
			<td><%= mainstay.getFirstName() %></td>
			<td><%= mainstay.getMiddleName() %></td>
			<td><%= mainstay.getLastName() %></td>
			<td>
				<liferay-ui:icon-menu>
				
					<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="viewMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="viewMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
						<portlet:param name="approve" value="1" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="preview" message="View" url="<%= viewMainstay %>" />
						<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="approveMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="approveMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="add_user" message="Approve" url="<%= approveMainstay %>" />
					
				</liferay-ui:icon-menu>
			</td>
		</tr>
		
	<%}%>
	</table>
	</center>
	<div class="taglib-search-iterator-page-iterator-bottom">
		<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
	</div>
	</c:when>
	
<c:when test='<%= tabs1.equals("Approved") %>'>
	
	
	<%
		List<Mainstay> mainstayNew = MainstayLocalServiceUtil.getByStatus(1);
		SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, 5, tabs1URL, null, "");
		List mainstayList = ListUtil.subList(mainstayNew, searchContainer.getStart(), searchContainer.getEnd());
		int total = mainstayNew.size();
		searchContainer.setTotal(total);
	%>

	<center>
	<table class="taglib-search-iterator" style="width:100%" cellspacing="0" cellpadding="2">
		<tr class='results-header'>
			<th><liferay-ui:message key="sNo" /></th>
			<th><liferay-ui:message key="first-name" /></th>	
			<th><liferay-ui:message key="middle-name" /></th>
			<th><liferay-ui:message key="last-name" /></th>
			<th></th>
		</tr>	

	<%
		for(int i=0; i<mainstayList.size(); i++){

			Mainstay mainstay = (Mainstay) mainstayList.get(i);
			String className = ( ( i%2 == 0 ) ? "portlet-section-body results-row" : "portlet-section-body results-row alt"); 
			String classNameHover = className+" hover";
	%>
		<tr class='<%= className %>'; onmouseout="this.className = '<%=className%>'" onmouseover="this.className = '<%=classNameHover%>'"> 
			<td><%= Integer.toString(searchContainer.getStart() + i + 1)%></td>
			<td><%= mainstay.getFirstName() %></td>
			<td><%= mainstay.getMiddleName() %></td>
			<td><%= mainstay.getLastName() %></td>
			<td>
				<liferay-ui:icon-menu>
				
					<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="viewMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="viewMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
					<portlet:param name="approve" value="0" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="preview" message="View" url="<%= viewMainstay %>" />
						<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="removeMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="removeMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="remove" message="Remove" url="<%= removeMainstay %>" />
					
				</liferay-ui:icon-menu>
			</td>
		</tr>	
	<%}%>
	</table>
	</center>
	<div class="taglib-search-iterator-page-iterator-bottom">
		<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
	</div>
	
	</c:when>
	
	<c:when test='<%= tabs1.equals("Pending") %>'>
	
	<%
		List<Mainstay> mainstayNew = MainstayLocalServiceUtil.getByStatus(2);
		SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, 5, tabs1URL, null, "");
		List mainstayList = ListUtil.subList(mainstayNew, searchContainer.getStart(), searchContainer.getEnd());
		int total = mainstayNew.size();
		searchContainer.setTotal(total);
	%>

	<center>
	<table class="taglib-search-iterator" style="width:100%" cellspacing="0" cellpadding="2">
		<tr class='results-header'>
			<th><liferay-ui:message key="sNo" /></th>
			<th><liferay-ui:message key="first-name" /></th>	
			<th><liferay-ui:message key="middle-name" /></th>
			<th><liferay-ui:message key="last-name" /></th>
			<th></th>
		</tr>	

	<%
		for(int i=0; i<mainstayList.size(); i++){
		
				Mainstay mainstay = (Mainstay) mainstayList.get(i);
				String className = ( ( i%2 == 0 ) ? "portlet-section-body results-row" : "portlet-section-body results-row alt"); 
				String classNameHover = className+" hover";
	%>
		<tr class='<%= className %>'; onmouseout="this.className = '<%=className%>'" onmouseover="this.className = '<%=classNameHover%>'"> 
			<td><%= Integer.toString(searchContainer.getStart() + i + 1)%></td>
			<td><%= mainstay.getFirstName() %></td>
			<td><%= mainstay.getMiddleName() %></td>
			<td><%= mainstay.getLastName() %></td>
			<td>
				<liferay-ui:icon-menu>
					<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="viewMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="viewMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
						<portlet:param name="approve" value="2" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="preview" message="View" url="<%= viewMainstay %>" />
						<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="approveMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="approveMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="add_user" message="Approve" url="<%= approveMainstay %>" />
					
				</liferay-ui:icon-menu>
			</td>
		</tr>	
	<%}%>
	</table>
	</center>
	<div class="taglib-search-iterator-page-iterator-bottom">
		<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
	</div>
	
	</c:when>
	
	<c:when test='<%= tabs1.equals("Rejected") %>'>
	
	<%
		List<Mainstay> mainstayNew = MainstayLocalServiceUtil.getByStatus(3);
		SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, 5, tabs1URL, null, "");
		List mainstayList = ListUtil.subList(mainstayNew, searchContainer.getStart(), searchContainer.getEnd());
		int total = mainstayNew.size();
		searchContainer.setTotal(total);
	%>

	<center>
	<table class="taglib-search-iterator" style="width:100%" cellspacing="0" cellpadding="2">
		<tr class='results-header'>
			<th><liferay-ui:message key="sNo" /></th>
			<th><liferay-ui:message key="first-name" /></th>	
			<th><liferay-ui:message key="middle-name" /></th>
			<th><liferay-ui:message key="last-name" /></th>
			<th></th>
		</tr>	

	<%
		for(int i=0; i<mainstayList.size(); i++){

			Mainstay mainstay = (Mainstay) mainstayList.get(i);
			String className = ( ( i%2 == 0 ) ? "portlet-section-body results-row" : "portlet-section-body results-row alt"); 
			String classNameHover = className+" hover";
	%>
		<tr class='<%= className %>'; onmouseout="this.className = '<%=className%>'" onmouseover="this.className = '<%=classNameHover%>'"> 
			
			<td><%= Integer.toString(searchContainer.getStart() + i + 1)%></td>
			<td><%= mainstay.getFirstName() %></td>
			<td><%= mainstay.getMiddleName() %></td>
			<td><%= mainstay.getLastName() %></td>
			<td>
				<liferay-ui:icon-menu>
					<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="viewMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="viewMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
						<portlet:param name="approve" value="3" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="preview" message="View" url="<%= viewMainstay %>" />
						<portlet:actionURL windowState="<%= WindowState.NORMAL.toString() %>" var="approveMainstay">
						<portlet:param name="struts_action" value="/ext/registration/mainstayRegistration" />
						<portlet:param name="<%= Constants.CMD %>" value="approveMainstay" />
						<portlet:param name="mainstayId" value="<%= String.valueOf(mainstay.getMainstayId()) %>" />
					</portlet:actionURL>
					
					<liferay-ui:icon image="add_user" message="Approve" url="<%= approveMainstay %>" />
					
				</liferay-ui:icon-menu>
			</td>
		</tr>	
	<%}%>
	</table>
	</center>
	<div class="taglib-search-iterator-page-iterator-bottom">
		<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
	</div>
	</c:when>
</c:choose>
		